﻿using System;
using SharpDepend.Classes;
using SharpDepend.Resources;

namespace SharpDepend
{
    public static class Manager
    {
        private static bool mPlatformSet;

        public static void ForcePlatform(Platform platform)
        {
            if (mPlatformSet)
            {
                throw new Exception("Platform can only be set at once");
            }
            CurrentPlatform = platform;
            mPlatformSet = true;
        }
        
        public static Platform CurrentPlatform { get; set; }

        private static TouchManager sTouchManager;

        internal volatile static object GraphicsLocker = new object();

        public static ISocketClientManager SocketClientManager { get; set; }

        public static ISocketServerManager SocketServerManager { get; set; }

        public static ISocketMulticastManager SocketMulticastManager { get; set; }

        public static IThreadManager ThreadManager { get; set; }

        public static IAESSecurityManager AESSecurityManager { get; set; }

        public static IGUITimerManager GUITimerManager { get; set; }

        public static IFileManagerManager FileManager { get; set; }

        public static IMultiTouchManager MultiTouch { get; set; }

        public static IDialogManager DialogManager { get; set; }

        public static IGraphicsDisplayManager GraphicsDisplayManager { get; set; }

        public static IKeyboardManager KeyboardManager { get; set; }

        public static ICameraManager CameraManager { get; set; }
        
        public static IStopwatchManager StopwatchManager { get; set; }
        
        public static IEnviromentStatisticsManager EnviromentStatisticsManager { get; set; }

        public static void Registrate(
            ISocketClientManager socketClient,
            ISocketServerManager socketServer,
            ISocketMulticastManager socketMulticastManager,
            IThreadManager thread,
            IAESSecurityManager aesSecurityManager,
            IGUITimerManager guiTimerManager,
            IFileManagerManager fileManager,
            IMultiTouchManager multiTouch,
            IDialogManager dialogManager,
            IGraphicsDisplayManager graphicsDisplayManager,
            IKeyboardManager keyboardManager,
            ICameraManager cameraManager,
            IStopwatchManager stopwatchManager,
            IEnviromentStatisticsManager enviromentStatisticsManager)
        {
            SocketClientManager = socketClient;
            SocketServerManager = socketServer;
            SocketMulticastManager = socketMulticastManager;
            ThreadManager = thread;
            AESSecurityManager = aesSecurityManager;
            GUITimerManager = guiTimerManager;
            FileManager = fileManager;
            MultiTouch = multiTouch;
            DialogManager = dialogManager;
            GraphicsDisplayManager = graphicsDisplayManager;
            KeyboardManager = keyboardManager;
            CameraManager = cameraManager;
            StopwatchManager = stopwatchManager;
            EnviromentStatisticsManager = enviromentStatisticsManager;

            sTouchManager = new TouchManager(GUITimerManager);

            // TEST.
            //FontReader reader = new FontReader();
            //reader.LoadFont(EmbeddedResources.GetResource("Fonts/gilb.ttf"));
        }
    }
}
